package org.wanho.shop.mapper;

import org.wanho.shop.entity.Order;
import org.wanho.shop.entity.User;
import org.wanho.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Author：汤小洋
 * Date：2023-04-27 15:19
 * Description：<描述>
 */
public class OrderMapper implements RowMapper<Order> {
    @Override
    public Order mapRow(ResultSet rs) throws SQLException {
        Order order = new Order();
        order.setId(rs.getInt("id"));
        order.setNo(rs.getString("no"));
        order.setPrice(rs.getDouble("price"));
        User user = new User();
        user.setId(rs.getInt("user_id"));
        order.setUser(user);
        return order;
    }
}
